<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/9/26
 * Time: 17:54
 */

namespace App\Http\Middleware;
use Closure,Session,Redirect;
use App\Module\EntMemberInfo;

class MemberSession
{
    public function handle($request, Closure $next)
    {
        $MName = Session::get('MName');
        $MKey = Session::get('MKey');
        if ($MName != '' && $MKey != '') {
            $entMemberInfo = EntMemberInfo::where('UserName',$MName)->where('LoginKey',$MKey)
                ->where('DeleteMark','1')
                ->where('States','1')
                ->first();
            if (count($entMemberInfo) == 0) {
                return redirect('/');
            }
        } else {
            return redirect('/');
        }
        return $next($request);
    }
}